#!/bin/bash

set -e

OPS_SERVER=192.168.88.81
OPS_USER=root
# 设置环境---  run_env.sh
echo "设置运行环境"
bash <(curl -sSL https://gitee.com/michelalive/shell_scripts/raw/master/kubernetes/1_21_14/online_install/cluster/setEnv.sh)

# 安装docker--- b_install_docker.sh
echo "软件安装"
bash <(curl -sSL https://gitee.com/michelalive/shell_scripts/raw/master/kubernetes/1_21_14/online_install/cluster/pre_install.sh)

# master初始化---  master_init.sh   ---仅 Master 执行
echo  "集群初始化"
bash <(curl -sSL https://gitee.com/michelalive/shell_scripts/raw/master/kubernetes/1_21_14/online_install/cluster/master_init.sh)

read -p "请输入你管理机器的主机密码: " -s PASSWORD
echo " "
CMD="rm -rf ~/.kube && mkdir ~/.kube"
sshpass -p $PASSWORD ssh -o ConnectTimeout=10 $OPS_USER@$OPS_SERVER "$CMD"
sshpass -p "$PASSWORD" scp /etc/kubernetes/admin.conf "$OPS_USER@$OPS_SERVER:~/.kube/config"

unset PASSWORD
